package com.tanhua.dubbo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.domian.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {



    /*@Select("SELECT COUNT(*) from tb_user_info\n" +
            "WHERE id IN (SELECT black_user_id FROM tb_black_list WHERE user_id = #{userId})")*/
    @Select("SELECT COUNT(*) FROM tb_user_info as info\n" +
            "INNER JOIN tb_black_list as list\n" +
            "ON info.id = list.black_user_id\n" +
            "WHERE list.user_id = #{userId}\n")
    public Integer count(Long userId);

    /*@Select("SELECT * from tb_user_info\n" +
            "WHERE id IN (SELECT black_user_id FROM tb_black_list WHERE user_id = #{userId}) LIMIT #{page},#{size}\n")*/
    @Select("SELECT info.* FROM tb_user_info as info\n" +
            "INNER JOIN tb_black_list as list\n" +
            "ON info.id = list.black_user_id\n" +
            "WHERE list.user_id = #{userId}\n" +
            "LIMIT #{page},#{size}")
    List<UserInfo> findblackList(int page, int size, Long userId);


    @Select("SELECT * FROM tb_user_info LIMIT #{page},#{size}")
    List<UserInfo> findUserInfoPage(int page, int size);

}
